import { systemPreferences, dialog } from "electron";

//获取麦克风权限

const getMediaAccessStatus = async () => {
  //检测麦克风权限是否开启
  let getMediaAccessStatus =
    systemPreferences.getMediaAccessStatus("microphone");
  const cameraPrivilege = systemPreferences.getMediaAccessStatus("camera");
  dialog
    .showMessageBox({
      type: "warning",
      title: "消息提醒",
      message: "调试",
      buttons: ["是"],
      detail: JSON.stringify(getMediaAccessStatus),
    })
    .then((result) => {
      console.log(result);
      let response = result.response;
      console.log(response);
    })
    .catch((err) => {
      console.log(err);
    });
  if (getMediaAccessStatus !== "granted") {
    //请求麦克风权限
    await systemPreferences.askForMediaAccess("microphone");
  }

  if (cameraPrivilege !== "granted") {
    await systemPreferences.askForMediaAccess("camera");
  }
};
